package com.beichuan_travel.controller;

import com.beichuan_travel.model.vo.ResultVO;
import com.beichuan_travel.service.SearchService;
import com.beichuan_travel.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Api(tags = "首页上方搜索")
@RequestMapping("/search")
public class SearchController {

    @Resource
    SearchService searchService;

    @Resource
    ResponseResult responseResult;


    @ApiOperation(value = "获得搜索的历史记录")
    @ApiImplicitParam(name = "uid", value = "用户id", required = true, dataType = "int", paramType = "path")
    @GetMapping("/v1/history/{uid}")
    public ResultVO getHistory(@PathVariable("uid") int uid, @RequestParam("limit") int limit) {
        return responseResult.ok(searchService.querySearchHistory(uid, limit));
    }


    @ApiOperation(value = "全局搜索")
    @ApiImplicitParam(name = "keyword", value = "搜索的关键字", required = true, dataType = "string", paramType = "query")
    @GetMapping
    public ResultVO searchAll(@RequestParam("keyword") String keyword) {
        return null;
    }


    @ApiOperation(value = "按种类搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "category", value = "种类，如酒店，自由行等", required = true, dataType = "string", paramType = "path")
    })
    @GetMapping("/v1/{category}")
    public ResultVO searchCategory(@PathVariable("category") String category, @RequestParam("keyword") String keyword) {
        return null;
    }

}
